#include <stdio.h>
#include <stdlib.h>
#define r(a,b) for(i=0;i<a;i++) p(b)
#if defined __GNUC__
  #define cls()  system("clear")
  #define p(i)  printf("%s",map[i])
  #define t(i,s)  r(s,11);printf("%s",map[i])
  const char *map1[]={"\u254b", "\u250f","\u2513","\u2517","\u251b", "\u2533","\u252b","\u253b","\u2523", "\u2501","\u2503"," ","\r","\n","\0"};
  const char *map[]={"\u253c", "\u250c","\u2510","\u2514","\u2518", "\u252c","\u2524","\u2534","\u251c", "\u2500","\u2502"," ","\r","\n","\0"};
#else
  #define cls() clrscr()
  #define p(i)  printf("%c",map[i])
  #define t(i,s)  r(s,11);printf("%c",map[i])
  int map[]={197, 218,191,192,217, 194,180,193,195, 196,179,32,13,10};
#endif
 

void row(int n,int x,int isUp,int isDown,int left){
  int i,j,w=n*2+1,h;

  if(isUp){
   t(1,left);
   for(j=1;j<x;j++){
	r(w,9);p(5);
   }
   r(w,9); p(isUp?2:6);  p(13);
  }

  for(h=0;h<n;h++){
    t(10,left);
    for(j=1;j<x;j++){
      r(w,11);
      p(10);
    }
    r(w,11);p(10); p(13);
  }

  t(isDown?3:8,left);
  for(j=1;j<x;j++){
	r(w,9); p(isDown?7:0);
  }
  r(w,9); p(isDown?4:6) ;p(13);
}

void tab(int x,int y,int n,int left)
{
   int i;
   for(i=0;i<y;i++){
	row(n,x,i==0,i==y-1,left);
   }
}

main(){
	int i=8,j;
	cls(); printf("\n");tab(11,7, 2,3); getchar();
	for(j=i;i--;) {
	 cls();
	 tab(j-i,j-i,i,0);
	 getchar();
	}
}
